<div class="SipeiMain_r fr">
    <h2 class="clearfix fonts_18 height45 fontc_444"><?php echo $this->title; ?></h2>
    <div class="clearfix back_bgf border_3 border_c pr30 pt20 pb20 height32 fontc_666">
        <form class="clearfix pb10" action="<?php echo $this->createUrl('/membership/default/index')?>" method="GET">
            <table with="100%">
                <tbody>
                    <tr>
                        <td width="87" valign="top" align="right" class="pt10 pr2" >代码：</td>
                        <td width="250" class="pt10">
                            <input type="text" value="<?php echo $search['membership_code'] ?>" name="membership_code" class="w150 pt5 pr5 pb5 pl5 height20 border_c border_3 fontc_666">
                        </td>
                        <td width="67" valign="top" align="right" class="pt10 pr2">设置名称：</td>
                        <td width="250" class="pt10">
                            <input type="text" value="<?php echo $search['membership_name'] ?>" name="membership_name" class="w150 pt5 pr5 pb5 pl5 height20 border_c border_3 fontc_666">
                        </td>
                        <td width="110" align="right" class="pt10"><input type="submit" value="查询" class="cursor b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12" /></td>
                    </tr>
                </tbody>
            </table>
        </form>
    </div>
    <div class="clearfix back_bgf border_c mt15 pt20 pb20">
        <div class="clearfix pb20 pl30">
            <input type="button" onclick="membershipadd()" style="margin-right:30px;" value="新增" class="cursor fr b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12" />
            <input type="button" value="删除" onclick="delete_all()" class="fl b_a_n border_3 back_bgfb w80 ml20 height32 fontc_FFF fonts_12 cursor" />
        </div>
        <form>
            <table class="height40" width="100%">
                <thead class="back_bgf5 fontc_666">
                    <tr>
                    	<th width="35" align="right" class="m_hr_t m_hr_b pr10"><input type="checkbox" class="checkboxs"></th>
                        <th width="160" align="center" class="m_hr_t m_hr_b">代码</th>
                        <th width="100" align="center" class="m_hr_t m_hr_b">名称</th>
                        <th width="160" align="center" class="m_hr_t m_hr_b">所属学段</th>
                        <th width="60" align="center" class="m_hr_t m_hr_b">是否生效</th>
                        <th width="160" align="center" class="m_hr_t m_hr_b">备注</th>                   
                        <th width="115" align="center" class="m_hr_t m_hr_b">操作</th>
                    </tr>
                </thead>
                <tbody class="fontc_444">
                    <?php if ($memebership): foreach ($memebership as $one): ?>
                            <tr>
                            	<td align="right" class="m_hr_b pr10"><input type="checkbox" name="deleteAll[]" value="<?php echo $one['membership_id'];?>" class="checkbox"></td>
                                <td align="center" class="m_hr_b fontc_666"><?php echo $one['membership_code']; ?></td>
                                <td align="center" class="m_hr_b"><?php echo $one['membership_name']; ?></td>
                                <td align="center" class="m_hr_b"><?php echo $one['edutype_name']; ?></td>
                                <td align="center" class="m_hr_b">
                                 <input type="checkbox" disabled='' <?php if($one['disabled'] == 1)echo "checked";?>/>
                                 </td>
                               
                                <td align="center" class="m_hr_b"><?php echo $one['description']; ?></td>
                                <td align="center" class="m_hr_b">
                                    <a onclick="javascript:window.location.href = '<?php echo $this->createUrl('/membership/default/subordinate', array('membership_id' => $one['membership_id'])); ?>'" class="mr10" 
                                       title="学校人数添加" ><img src="/themes/default/images/Sipei/plus.png" class="cursor" /></a>
                                    <a onclick="editmembership(<?php echo $one['membership_id']; ?>)" class="mr10 cursor"><img src="/themes/default/images/Sipei/edit.png" title="编辑"/></a>
                                    <a onclick="deletemembership(<?php echo $one['membership_id']; ?>, $(this))" title="删除" ><img src="/themes/default/images/Sipei/delate.png" class="cursor" /></a>
                                </td>
                            </tr>
                            <?php
                        endforeach;
                    else:
                        ?>
                        <tr>
                            <td colspan='7' class="m_hr_b pr15"><h2 align="center">当前没有您要的数据存在!</h2></td>
                        </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </form>
        <?php $this->renderPartial('//partial/partial_pager', array('pages' => $pages, "url" => $pageUrl)); ?>
    </div>
</div>

<script type="text/javascript" >
            var api;
            function membershipadd()
            {
                api = $.dialog({
                    id: 'testID2',
                    lock: true,
                    fixed: true,
                    title: "新增",
                    width: 500,
                    height: 450,
                    max: false,
                    min: false
                });
                $.get('/membership/default/membershipadd', function(data) {
                    api.content(data);
                });
            }
            function deletemembership(id, $this) {
                $.dialog.confirm('确定删除吗', function() {
                     $.get('/membership/default/delete_all', {id: id}, function(data) {
                        if (data == 1) {
                        	location.reload();
                        } else if(data == 3){
							$.dialog.alert("请清空学生在籍人数数据后再进行删除操作");
                        }else{
                            $.dialog.alert("删除失败");
                        }
                    });
                });
            }
            
            function delete_all(){
            	var aa='';
            	$("input[name='deleteAll[]']:checkbox:checked").each(function(){
						aa+=$(this).val()+',';
					});
					if(aa == ''){
						$.dialog.alert("请选择要删除条目");
						return false;
					}
					$.dialog.confirm('确定删除所选数据吗', function() {

            		aa+=0;
            	
            		$.get('/membership/default/delete_all', {id: aa}, function(data) {
            			if (data == 1) {
            				location.reload();
                        } else if(data == 3){
							$.dialog.alert("请清空学生在籍人数数据后再进行删除操作");
                        }else{
                            $.dialog.alert("删除失败");
                        }
            		   
            		});
            	});
            }
            function editmembership(id)
            {
                api = $.dialog({
                    id: 'testID2',
                    lock: true,
                    fixed: true,
                    title: "编辑",
                    width: 500,
                    height: 450,
                    max: false,
                    min: false
                });
                $.get('/membership/default/membershipadd', {membership_id: id,time:new Date()}, function(data) {
                    api.content(data);
                });
            }
				$(function() {
                    $(".checkboxs").click(function() {
                        var checkedS = $(this).attr("checked");
                        if (checkedS) {
                            $(".checkbox").attr("checked", true)
                        } else {
                            $(".checkbox").removeAttr("checked")
                        }
                    })

                })
</script>